package com.qxl.forest.core.auth.validator.impl;

import com.qxl.forest.business.persistence.dao.UserDao;
import com.qxl.forest.business.persistence.entity.User;
import com.qxl.forest.core.auth.validator.IReqValidator;
import com.qxl.forest.core.auth.validator.dto.Credence;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: qiuxinlin
 * @Dercription: 账号密码验证
 * @Date: 2018/1/5
 */
@Service
public class DbValidator implements IReqValidator {

    @Autowired
    UserDao userDao;

    @Override
    public boolean validate(Credence credence) {
        User user = userDao.findByAccount(credence.getCredenceName());
        if (user != null) {
            return true;
        } else {
            return false;
        }
    }
}
